# -*- coding: utf-8 -*-
from db.mysql import MysqlClient
import requests
from common.helper import Helper
from common.config import *
from itertools import product
class Spider(object):
    def __init__(self):
        self.mysql = MysqlClient()
        self.name = "中华新生活意外伤害保险"

    def genProductInfo(self):
        plan = {
            "planA": {
                # 年龄段
                "year": ["45-65","66-75","76-80"],
                # 性别
                "gender": ["M", "F"],
                # 保障天数
                "days": ["7d", "15d", "30d", "1y"],
                # 保障人数
                "people_count": ["1"],
                # 一般意外伤残/死亡
                "accident_death": ["100000"],
                # 飞机意外伤残/死亡
                "airplane_death": ["1000000"],
                # 火车意外伤残/死亡
                "train_death": ["100000"],
                # 轮船伤残/死亡
                "ship_death": ["100000"],
                # 营运车辆伤残/死亡
                "passenger_death": ["100000"],
                # 意外伤害医疗
                "accident_medical": ["20000"],
                # 意外伤害骨折
                "accident_fracture": ["10000"],
                # 意外伤害救护车
                "accident_ambulance": ["2000"],
                # 意外伤害住院津贴
                "accident_hospital": [""],
                # 意外重症监护病房津贴
                "serious_allowance": [""]
            },
            "planB": {
                # 年龄段
                "year": ["45-65","66-75","76-80"],
                # 性别
                "gender": ["M", "F"],
                # 保障天数
                "days": ["7d", "15d", "30d", "1y"],
                # 保障人数
                "people_count": ["1"],
                # 一般意外伤残/死亡
                "accident_death": ["200000"],
                # 飞机意外伤残/死亡
                "airplane_death": ["1000000"],
                # 火车意外伤残/死亡
                "train_death": ["100000"],
                # 轮船伤残/死亡
                "ship_death": ["100000"],
                # 营运车辆伤残/死亡
                "passenger_death": ["100000"],
                # 意外伤害医疗
                "accident_medical": ["20000"],
                # 意外伤害骨折
                "accident_fracture": ["10000"],
                # 意外伤害救护车
                "accident_ambulance": ["2000"],
                # 意外伤害住院津贴
                "accident_hospital": ["100/天"],
                # 意外重症监护病房津贴
                "serious_allowance": ["100/天"]
            }
        }
        for k in plan:
            for v in product(plan[k]["year"], plan[k]["gender"], plan[k]["days"], plan[k]["people_count"],
                             plan[k]["accident_death"], plan[k]["airplane_death"], plan[k]["train_death"],
                             plan[k]["ship_death"], plan[k]["passenger_death"], plan[k]["accident_medical"],
                             plan[k]["accident_fracture"], plan[k]["accident_ambulance"], plan[k]["accident_hospital"],
                             plan[k]["serious_allowance"]):
                data = Helper.formatProductInfo(plan[k], v)
                yield data \
    # 执行爬虫
    def requestJson(self,null="null"):
        for v in self.genProductInfo():
                if v["days"] == "7d":
                    days = "7D"
                elif v["days"] == "15d":
                    days = "15D"
                elif v["days"] == "30d":
                    days = "30D"
                else:
                    days = "12M"
                if v["accident_death"] == "200000":
                    data = '{"insuredEntity":{"sex":"'+v["gender"]+'","birthday":"'+str(2020-int(v["year"].split("-")[1]))+'-01-01"},"riskFactsList":[{"name":"factor_J0019C_019C21_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C21_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C21_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C21_amnt","key":"amnt","value":"200000"},{"name":"factor_J0019C_019C21_prem","key":"prem","value":""},{"name":"factor_J0019C_019C22_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C22_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C22_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C22_amnt","key":"amnt","value":"1000000"},{"name":"factor_J0019C_019C22_prem","key":"prem","value":""},{"name":"factor_J0019C_019C23_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C23_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C23_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C23_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C23_prem","key":"prem","value":""},{"name":"factor_J0019C_019C24_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C24_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C24_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C24_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C24_prem","key":"prem","value":""},{"name":"factor_J0019C_019C25_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C25_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C25_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C25_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C25_prem","key":"prem","value":""},{"name":"factor_J0019C_019C26_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C26_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C26_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C26_amnt","key":"amnt","value":"20000"},{"name":"factor_J0019C_019C26_prem","key":"prem","value":""},{"name":"factor_J0019C_019C27_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C27_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C27_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C27_amnt","key":"amnt","value":"100"},{"name":"factor_J0019C_019C27_prem","key":"prem","value":""},{"name":"factor_J0019C_019C28_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C28_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C28_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C28_amnt","key":"amnt","value":"100"},{"name":"factor_J0019C_019C28_prem","key":"prem","value":""},{"name":"factor_J0019C_019C29_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C29_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C29_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C29_amnt","key":"amnt","value":"10000"},{"name":"factor_J0019C_019C29_prem","key":"prem","value":""},{"name":"factor_J0019C_019C30_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C30_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C30_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C30_amnt","key":"amnt","value":"2000"},{"name":"factor_J0019C_019C30_prem","key":"prem","value":""}],"productInfo":{"id":"297037078742371","productCode":"J0019C","name":"中华新生活意外伤害保险","serverTime":"2020-04-14","riskList":[{"id":"2970370787423711","riskCode":"J0019C","nameCn":"中华新生活意外伤害保险","mainCovRiderFlg":"M","mult":null,"dutyList":[{"dutyId":"29703707874237111","riskCode":"J0019C","dutyCode":"019C21","dutyName":"一般意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"200000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"20万","k":"200000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237112","riskCode":"J0019C","dutyCode":"019C22","dutyName":"飞机意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"1000000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"100万","k":"1000000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237113","riskCode":"J0019C","dutyCode":"019C23","dutyName":"火车意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"10万","k":"100000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237114","riskCode":"J0019C","dutyCode":"019C24","dutyName":"轮船意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"10万","k":"100000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237115","riskCode":"J0019C","dutyCode":"019C25","dutyName":"营运汽车意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"10万","k":"100000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237116","riskCode":"J0019C","dutyCode":"019C26","dutyName":"意外伤害医疗","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"20000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"2万","k":"20000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237117","riskCode":"J0019C","dutyCode":"019C27","dutyName":"意外伤害住院津贴","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C27","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C27","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C27","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"100","k":"100"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C27","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237118","riskCode":"J0019C","dutyCode":"019C28","dutyName":"意外伤害重症监护病房津贴","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C28","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C28","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C28","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"100","k":"100"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C28","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237119","riskCode":"J0019C","dutyCode":"019C29","dutyName":"意外伤害骨折津贴","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"10000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"1万","k":"10000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237120","riskCode":"J0019C","dutyCode":"019C30","dutyName":"意外伤害救护车","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"'+days+'"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"12M"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"2000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"2000","k":"2000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":null}]}],"extProperties":[{"field":"RnewFlag","name":"自动续保标记（续保次数）","val":"N"}]}]}}'
                else:
                    data = '{"insuredEntity":{"sex":"'+v["gender"]+'","birthday":"'+str(2020-int(v["year"].split("-")[1]))+'-01-01"},"riskFactsList":[{"name":"factor_J0019C_019C21_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C21_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C21_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C21_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C21_prem","key":"prem","value":"168.00"},{"name":"factor_J0019C_019C22_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C22_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C22_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C22_amnt","key":"amnt","value":"1000000"},{"name":"factor_J0019C_019C22_prem","key":"prem","value":"11.00"},{"name":"factor_J0019C_019C23_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C23_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C23_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C23_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C23_prem","key":"prem","value":"3.00"},{"name":"factor_J0019C_019C24_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C24_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C24_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C24_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C24_prem","key":"prem","value":"1.50"},{"name":"factor_J0019C_019C25_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C25_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C25_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C25_amnt","key":"amnt","value":"100000"},{"name":"factor_J0019C_019C25_prem","key":"prem","value":"4.50"},{"name":"factor_J0019C_019C26_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C26_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C26_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C26_amnt","key":"amnt","value":"20000"},{"name":"factor_J0019C_019C26_prem","key":"prem","value":"132.00"},{"name":"factor_J0019C_019C29_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C29_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C29_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C29_amnt","key":"amnt","value":"10000"},{"name":"factor_J0019C_019C29_prem","key":"prem","value":"71.00"},{"name":"factor_J0019C_019C30_insuYear","key":"insuYear","value":"'+days+'"},{"name":"factor_J0019C_019C30_payIntv","key":"payIntv","value":"0"},{"name":"factor_J0019C_019C30_payEndYear","key":"payEndYear","value":"1000"},{"name":"factor_J0019C_019C30_amnt","key":"amnt","value":"2000"},{"name":"factor_J0019C_019C30_prem","key":"prem","value":"33.00"}],"productInfo":{"id":"297037078742371","productCode":"J0019C","name":"中华新生活意外伤害保险","serverTime":"2020-04-14","riskList":[{"id":"2970370787423711","riskCode":"J0019C","nameCn":"中华新生活意外伤害保险","mainCovRiderFlg":"M","mult":null,"dutyList":[{"dutyId":"29703707874237111","riskCode":"J0019C","dutyCode":"019C21","dutyName":"一般意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"200000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"20万","k":"200000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C21","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237112","riskCode":"J0019C","dutyCode":"019C22","dutyName":"飞机意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"1000000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"100万","k":"1000000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C22","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237113","riskCode":"J0019C","dutyCode":"019C23","dutyName":"火车意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"10万","k":"100000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C23","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237114","riskCode":"J0019C","dutyCode":"019C24","dutyName":"轮船意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"10万","k":"100000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C24","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237115","riskCode":"J0019C","dutyCode":"019C25","dutyName":"营运汽车意外身故/伤残","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"100000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"10万","k":"100000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C25","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237116","riskCode":"J0019C","dutyCode":"019C26","dutyName":"意外伤害医疗","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"20000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"2万","k":"20000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C26","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237119","riskCode":"J0019C","dutyCode":"019C29","dutyName":"意外伤害骨折津贴","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"10000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"1万","k":"10000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C29","ctrlType":"P","effacted":null}]},{"dutyId":"29703707874237120","riskCode":"J0019C","dutyCode":"019C30","dutyName":"意外伤害救护车","choflg":"M","vpu":"1000","calmode":null,"mult":null,"rate":null,"extProperties":null,"riskInputFactors":[{"key":"insuYear","name":"保险期间","comp":"SingleComboBox","val":"1","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"7天","k":"7D"},{"v":"15天","k":"15D"},{"v":"30天","k":"30D"},{"v":"180天","k":"6M"},{"v":"1年","k":"'+days+'"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":null},{"key":"payIntv","name":"交费间隔","comp":"SingleComboBox","val":"0","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"一次交清","k":"0"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":null},{"key":"payEndYear","name":"交费期间","comp":"SingleComboBox","val":"1000","nullable":"false","required":"true","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"趸交","k":"1000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":"insuredPeople_birthday"},{"key":"amnt","name":"保额","comp":"NumberTextBox","val":"2000","nullable":"true","required":"false","maxVal":"0","minVal":"0","desc":null,"dic":[{"v":"2000","k":"2000"}],"readonly":"true","disabled":"true","dataType":"P","mod":"1","dutyCode":"019C30","ctrlType":"P","effacted":null}]}],"extProperties":[{"field":"RnewFlag","name":"自动续保标记（续保次数）","val":"N"}]}]}}'
                payload = data.encode("utf-8")
                r = requests.post( url = domain[self.name]["url"],headers=domain[self.name]["header"],data=payload)
                if r.status_code == 200 and "试算成功" in r.text:
                    price = r.json()["data"]["ssResult"]["insurances"][0]["businessObj"]["policyPrem"]
                    data = {
                        "name":self.name,
                        "company":"中华保险",
                        "price":price
                    }
                    data.update( v )
                    Helper.mergeTable(self.name,self.mysql,data )
